<template>
  <div class='container'>
    <el-dialog
      title="题目审核"
      :visible="CheckDialog"
      width="30%"
      @close="closeDialog"
      @open="openDialog">
        <el-radio-group v-model="form.chkState">
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="2">拒绝</el-radio>
        </el-radio-group>
        <el-input
         type="textarea"
         :rows="2"
         placeholder="请输入审核意见"
         v-model="form.chkRemarks"
         class="mytext">
        </el-input>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeDialog">取 消</el-button>
        <el-button 
          type="primary" 
          @click="fetchCheck">确 定
      </el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'questionsCheck',
  props: {
    CheckDialog: {
      type: Boolean,
      default: false
    },
    CheckId: {
      type: Number
    }
  },
  data() {
    return {
      form: {
        id: '',
        chkState: 1,
        chkRemarks: '',
      }
    }
  },
  methods: {
    closeDialog() {
      this.$emit('close-checkdialog')
      this.form.chkRemarks = ''
      this.form.chkState = 1
    },
    openDialog() {
      this.form.id = this.CheckId
    },
    async fetchCheck() {
      if (this.form.chkRemarks.trim() === '') {
        this.$message.warning('请输入审核意见')
        return
      }
      await  choiceCheck(this.form)
      this.$message.success('操作成功')
      this.closeDialog()
    }
  }
}
</script>

<style scoped>
div /deep/ .el-dialog__footer {
  text-align: right;
}
div /deep/ .mytext {
  margin-top: 20px;
}
</style>
